import inspect

frame = None


def foo():
    bar()


def bar():
    global frame
    frame = inspect.currentframe()


def gen_func():
    yield 1
    name = "leo"
    yield 2
    age = 11
    return "done"


if __name__ == '__main__':
    # foo()
    # print(frame.f_code.co_name)
    # caller_frame = frame.f_back
    # print(caller_frame.f_code.co_name)
    import dis
    gen = gen_func()
    print(dis.dis(gen))
    print(gen.gi_frame.f_lasti)
    print(gen.gi_frame.f_locals)
    next(gen)
    print(gen.gi_frame.f_lasti)
    print(gen.gi_frame.f_locals)
